import $app from '../$app';


export default {
	//商标补正+版权补正 列表，typeNum=>1商标 2版权
	// 商标详情+版权详情（美术+软著），补正列表 => data.bz_list:[]，里面的字段，都是一模一样的
	tabMcolTm(that,typeNum) {
		let out = [{
				title: "期限",
				width: 180,
				render: (h, params) => {
					let {
						row: {
							limit_date,
							state, // 0未处理 1已经处理
						}
					} = params;

					return h(
						"div", {
							class: (state == 0 && "cRed")
						},
						limit_date
					);
				}
			},
			{
				title: "创建日期",
				width: 180,
				key: "created_at"
			},
			{
				title: "附件（点击下载）",
				render: (h, params) => {
					//goods_type:100实用新型、101外观设计、102发明
					let {
						goods_type,
						orderInfo,
						orLiInfo
					} = that;
					// console.log(goods_type,params.row)

					let {
						row: {
							state, // 0未处理 1已经处理
							note_file_path, //通知书文件
						}
					} = params;

					let out = [
						h(
							"div", {
								class: "lineH1d5   " + (state == 0 ? ' cRed' : ' c999 ')
							},
							[
								h("i", {
									class: "iconfont marginR5 " + $app.fileIcon(note_file_path)
								}),
								h("span", {
									class: " textLine ",
									on: {
										click: () => {
											$app.fileNameAgainDown($app.getVal_fileUrl( note_file_path ), orderInfo, orLiInfo);
										}
									},
								}, "补正 通知书")
							]

						)
					];
					return h("div", out);
				}
			},
			{
				title: "状态 / 操作",
				width: 200,
				render: (h, params) => {
					let {
						row,
						row: {
							id,
							state // 0未处理 1已经处理
						}
					} = params;
					let out = "";

					if (state == 0) {
						out = h("div", [
							h(
								"Button", {
									class: "marginR10",
									props: {
										type: "primary",
										icon: "md-arrow-round-up",
										size: "small"
									},
									on: {
										click: () => {
											if(typeNum==1){//商标
												if(that.orderInfo.state==5){
													$app.goEditTm(that, id); //跳转编辑
												}else{
													$app.alert('当前订单状态，非待补正');
												}
												
												// $app.goEditTm(that, id); //跳转编辑
											}else{//版权
												$app.goEditTm(that, id); //跳转编辑
											}
											
										}
									}
								}, '补正'
							)
						]);
					} else {
						out = h(
							"div", {
								class: "",
							},
							[

								h(
									"Button", {
										class: "marginR20",
										props: {
											type: "primary",
											icon: "ios-search",
											size: "small"
										},
										on: {
											click: () => {
												if(typeNum==1){//商标
													that.buZ_Do(row);
												}else{//版权
													$app.alert('版权补正，历史记录','正在开发中');
												}
											}
										}
									}, '查看'
								),
								h(
									"span", {
										class: "cCCC ",
									},
									"已补正"
								),
							]
						);
					}

					return out;
				}
			}
		];
		return out;
	},

	
	// 商标通知书
	tm_notice_array(resData) {
		let out = [];

		// 通知书处理
		let {
			first_trial_note_path,
			first_trial_note_date,
			
			reject_note_path,
			reject_note_time,
			
			ignore_note_path,
			ignore_time,
			
			accept_notice_path,
			accept_time,
			
			register_cert_path,
			register_cert_time,

			withdraw_note_path,//撤回通知书
			withdraw_note_time,
			
			receipt_path
		} = resData;

		if ($app.package_file_url(first_trial_note_path)) {
			out.push({
				name: "初审公告通知书",
				time: first_trial_note_date,
				url: $app.getVal_fileUrl( first_trial_note_path )
			});
		}
		
		if ($app.package_file_url(reject_note_path)) {
			out.push({
				name: "驳回通知书",
				time: reject_note_time,
				url: $app.getVal_fileUrl( reject_note_path )
			});
		}
		
		if ($app.package_file_url(ignore_note_path)) {
			out.push({
				name: "不予受理通知书",
				time: ignore_time,
				url: $app.getVal_fileUrl( ignore_note_path )
			});
		}
		
		if ($app.package_file_url(accept_notice_path)) {
			out.push({
				name: "受理通知书",
				time: accept_time,
				url: $app.getVal_fileUrl( accept_notice_path )
			});
		}
		
		if ($app.package_file_url(register_cert_path)) {
			out.push({
				name: "商标证书",
				time: register_cert_time,
				url: $app.getVal_fileUrl( register_cert_path )
			});
		}
		
		if ($app.package_file_url(receipt_path)) {
			out.push({
				name: "商标局回执文件",
				time: '',
				url: $app.getVal_fileUrl( receipt_path )
			});
		}

		if ($app.package_file_url(withdraw_note_path)) {
			out.push({
				name: "撤回通知书",
				time: withdraw_note_time,
				url: $app.getVal_fileUrl( withdraw_note_path )
			});
		}
		
		return out;
	},

	// 商标通知书栏位
	tm_notice_array_col(that) {
		let out = [];
		out = [{
				title: "名 称",
				className: `f_14`,
				key: "name"
			},
			{
				title: "日 期",
				className: `f_14`,
				width: 200,
				key: "time",
				
				sortable:true,//启动 本地排序 功能
				sortType:'desc',
				key:'time'
			},
			
			{
				title: "操 作",
				className: `f_14`,
				width: 200,
				render: (h, params) => {
					//判断订单状态，显示不同按钮
					let {
						row
					} = params,
					btnList = [];
					btnList.push(
						h(
							"Button", {
								props: {
									icon: "md-download",
									size: "small",
									type: "primary"
								},
								on: {
									click: () => {
										let url=params.row.url;
										let orderInfo=that.orderInfo;
										let orLiInfo=that.orLiInfo;
										$app.fileNameAgainDown(url,orderInfo,orLiInfo);
									}
								}
							},
							`下载`
						)
					);
					return h("div", $app.judgeData(btnList) ? btnList : "-");
				}
			}
		];
		return out;
	}
};
